package com.jy.rhin.domain.document.tongji;

import com.jy.rhin.infra.repo.document.submission.po.DocumentValidateResultPO;
import com.jy.rhin.infra.repo.document.validation.query.DocumentValidateQueryHandler;
import com.jy.rhin.sdk.dto.tongji.JieDianRZSYDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 *
 */
@Service
@Slf4j
public class TongJiService {

    @Autowired
    private DocumentValidateQueryHandler documentValidateQueryHandler;


   public JieDianRZSYDto jieDianZZSY(String kaiShiRQ, String jieShuRQ){
       JieDianRZSYDto jieDianRZSYDto = new JieDianRZSYDto();
       List<DocumentValidateResultPO>  documentValidateResultPOList=  documentValidateQueryHandler.getDocumentValidateResult();
       jieDianRZSYDto.setWenDangZS(documentValidateResultPOList.size());
       jieDianRZSYDto.setJiaoYanWJS(documentValidateResultPOList.size());
       jieDianRZSYDto.setJiaoYanSBZS(documentValidateResultPOList.stream().filter(f->"0".equals(f.getValidateResult())).collect(Collectors.toList()).size());
       jieDianRZSYDto.setYiShangCWDZS(documentValidateResultPOList.stream().filter(f->"1".equals(f.getUploadResult())).collect(Collectors.toList()).size());
       jieDianRZSYDto.setJinRiXZWDZS(documentValidateResultPOList.stream()
               .filter(obj -> obj.getDocumentCreateTime().compareTo(new Date()) >= 0)
               .collect(Collectors.toList()).size());
       jieDianRZSYDto.setJinRiSCWDS(documentValidateResultPOList.stream()
               .filter(obj -> obj.getUploadTime().compareTo(new Date()) >= 0)
               .collect(Collectors.toList()).size());

       jieDianRZSYDto.setWenDangZBFXList(documentValidateQueryHandler.getwenDangZBFXList(null,null));
       jieDianRZSYDto.setWenDangZLFXList(documentValidateQueryHandler.getwenDangZBFXList(kaiShiRQ,jieShuRQ));
       return jieDianRZSYDto;
    }





}
